package com.tuonbed.qrqd;

import java.io.*;
import java.util.Properties;

/**
 * 参数加载类
 * @author tuonbed
 * @date 2020/1/11  10:19
 */
public class PROPARAM {

    private static final String DEFAULT_PROPERTIES="/application.properties";


    public static  String OUT_DIR ;

    public static  String INFO;

    public static  String LOGO_PATH;

    public static String TITLE;

    public static Integer CODE_START;

    public static Integer CODE_END;

    public static String FORMAT;

    public static Integer SIZE;

    static {

        Properties props = new Properties();
        InputStream inputStream = PROPARAM.class.getResourceAsStream(DEFAULT_PROPERTIES);
        //*.properties配置文件，要使用UTF-8编码，否则会现中文乱码问题
        BufferedReader bf = null;
        try {
            bf = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        try {
            props.load(bf);
            TITLE=props.getProperty("title");
            INFO=props.getProperty("prefix");
            CODE_START=props.getProperty("code_start")==null?1:Integer.valueOf(props.getProperty("code_start"));
            CODE_END=props.getProperty("code_end")==null?100:Integer.valueOf(props.getProperty("code_end"));
            FORMAT=props.getProperty("format")==null?"000000":props.getProperty("code_end");
            LOGO_PATH=props.getProperty("logodir");
            OUT_DIR=props.getProperty("outdir")==null?System.getProperty("user.dir")+File.separator:props.getProperty("outdir");
            SIZE=props.getProperty("size")==null?300:Integer.valueOf(props.getProperty("size"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
